package mwa.cs.filter;

import java.io.IOException;

import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletResponse;

@WebFilter(filterName = "/Filer1", urlPatterns = { "/*" }, servletNames = "*" , dispatcherTypes = { DispatcherType.REQUEST })
public class ClearCache implements Filter {

	public ClearCache() {
	}

	public void destroy() {

	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {

		HttpServletResponse response2 = (HttpServletResponse) response;
		response2.setHeader("Cache-Control", "no-cache");
		response2.setHeader("Cache-Control", "no-store");
		response2.setHeader("Pragma", "no-cache");
		response2.setDateHeader("Expires", 0);

		chain.doFilter(request, response);

	}

	public void init(FilterConfig fConfig) throws ServletException {

	}

}
